/**
 * Witontek.com.
 * Copyright (c) 2012-2018 All Rights Reserved.
 */
package test.inputstream;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * 
 * @author Long
 * @version $Id: InputStreamReader.java, v 0.1 2018年6月8日 下午3:53:14  xiaolong.ma  Exp $
 */
public class InputStreamReader1 {

    /**
     * 
     * @param args
     * @throws FileNotFoundException 
     */
    public static void main(String[] args) throws Exception {
        read2();
    }

    private static void read1() throws Exception {
        String fileName = "d:\\temp\\ch1.txt";
        InputStream is = new FileInputStream(fileName);
        InputStreamReader reader = new InputStreamReader(is); // 建立一个输入流对象reader  

        BufferedReader br = new BufferedReader(reader); // 建立一个对象，它把文件内容转成计算机能读懂的语言  
        String line = "";
        line = br.readLine();
        while (line != null) {
            line = br.readLine(); // 一次读入一行数据  
            System.out.println(line);
        }
        br.close();
    }

    private static void read2() throws Exception {
        String fileName = "d:\\temp\\ch1.txt";

        BufferedReader br = new BufferedReader(new FileReader(fileName)); // 建立一个对象，它把文件内容转成计算机能读懂的语言  
        String line = "";
        line = br.readLine();
        while (line != null) {
            line = br.readLine(); // 一次读入一行数据  
            System.out.println(line);
        }
        br.close();
    }

}
